package utils

import (
	"crypto/rand"
	"math/big"
)

const (
	numberBytes = "0123456789"
)

// GenerateNumeric 生成指定长度的随机数字
func GenerateNumeric(length int) string {
	b := make([]byte, length)
	for i := 0; i < length; {
		if idx, err := rand.Int(rand.Reader, big.NewInt(int64(len(numberBytes)))); err == nil {
			b[i] = numberBytes[idx.Int64()]
			i++
		}
	}
	return string(b)
}
